package com.rbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rbs.entity.Customers;
import com.rbs.entity.Department;
import com.rbs.mapper.CustomersMapper;
import com.rbs.service.ICustomersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 客户表 服务实现类
 * </p>
 *
 * @author lisl
 * @since 2024-04-24
 */
@Service
public class CustomersServiceImpl extends ServiceImpl<CustomersMapper, Customers> implements ICustomersService {

    @Autowired
    private CustomersMapper customersMapper;

    @Override
    public boolean findSameCustomerName(Customers customers) {
        LambdaQueryWrapper<Customers> wrapper=new LambdaQueryWrapper<Customers>().eq(Customers::getCStrcustomerid,customers.getCStrcustomerid());
        boolean flag=customersMapper.exists(wrapper);
        return flag;
    }

    @Override
    public List<Customers> findByName(Customers customers) {
        LambdaQueryWrapper<Customers> wrapper=new LambdaQueryWrapper<Customers>().like(customers.getCStrcustomername()!=null,Customers::getCStrcustomername,customers.getCStrcustomername());
        List<Customers> list = customersMapper.selectList(wrapper);
        return list;
    }
}
